"""
@File    :   serializer_func.py
@Time    :   2024/03/25 21:34:07
@Author  :   Qrj
@Email   :   923207736@qq.com
@description   :   pydantic模型字段的序列化方法
"""

from ipaddress import IPv4Address, IPv4Network

from pydantic import HttpUrl


def ipv4_address_serializer(ipv4_address: IPv4Address) -> str:
    """IPv4Address转字符串"""
    return str(ipv4_address)


def ipv4_address_list_serializer(ipv4_address_list: list[IPv4Address]) -> list[str]:
    """IPv4Address列表转字符串列表"""
    return [str(i) for i in ipv4_address_list]


def ipv4_network_serializer(ipv4_network: IPv4Network) -> str:
    """IPv4Network转字符串"""
    return str(ipv4_network)


def ipv4_network_list_serializer(ipv4_network_list: list[IPv4Network]) -> list[str]:
    """IPv4Network列表转字符串列表"""
    return [str(i) for i in ipv4_network_list]


def http_url_serializer(http_url: HttpUrl) -> str:
    """HttpUrl转字符串"""
    return str(http_url)


def http_url_list_serializer(http_url_list: list[HttpUrl]) -> list[str]:
    """HttpUrl列表转字符串列表"""
    return [str(i) for i in http_url_list]
